package com.shensi.adminCollect.utils.system;

import com.shensi.common.core.domain.entity.SysRole;
import com.shensi.common.core.domain.entity.SysUser;
import org.apache.commons.collections.CollectionUtils;

import java.util.List;

/**
 * @date 2023/7/27
 */
public class UserUtil {

    public static boolean hasRole(SysUser user, long roleId){
        List<SysRole> roles = user.getRoles();
        if (CollectionUtils.isNotEmpty(roles)) {
            for (SysRole role : roles) {
                if (role.getRoleId() == roleId) {
                    return true;
                }
            }
        }
        return false;
    }

}
